package com.aaa.controller;

import com.aaa.entity.Student;
import com.aaa.service.StudentService;
import com.aaa.vo.StudentVo;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/stu")
public class StudentController {
    @Autowired
    private StudentService studentService;
    //查所有2
    //以后接收前端的搜索数据时，独立封装一个新的实体类Vo view object视图对象
    @RequestMapping("/list/{current}/{pageSize}")
    public PageInfo<Student> list(@PathVariable Integer current, @PathVariable Integer pageSize, @RequestBody StudentVo studentVo){
        return studentService.selectAll(current,pageSize,studentVo);
    }
    //删除
    @GetMapping("/deleteById/{id}")
    public int deleteById(@PathVariable Integer id){
        return studentService.delete(id);
    }
    //添加
    @PostMapping ("/save")
    public int save(@RequestBody Student student){
        return studentService.add(student);
    }
    //修改
    @PostMapping ("/update")
    public int update(@RequestBody Student student){
        return studentService.update(student);
    }

}
